#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>

int Ackmann(int n, int m)
{
	if (m == 0)
		return n + 1;
	else if ((n == 0) & (m > 0))
		return Ackmann(m, 1);
	else if ((n > 0) & (m > 0))
		return Ackmann(m - 1, Ackmann(m, n - 1));
	else
		return -1;
}

int main()
{
	int n = 0;
	int m = 0;
	int result = 0;
	scanf("%d %d", &n, &m);
	result = Ackmann(n, m);
	printf("%d", result);
	return 0;
}